Repository navigation
feat(media): set a video bitrate, average or CBR (#1616) - #1979
Draft
cre8ive-marketing wants to merge 3 commits into
Draft
cre8ive-marketing wants to merge 3 commits into
cre8ive-marketing wants to merge 3 commits into
Conversation
Video presets get MediaOptions.VideoBitrateKbps and ConstantBitrate. The video is then encoded at that bitrate in software (never copied), with MediaEncoding.AtBitrate's average shape or CBR for x264/x265. A size limit that needs less wins, with notice.bitrate_lowered_for_size. Splits grey the option; VOB and DV keep their fixed rates. The gallery allow-list and SharedPresetVersions know both fields (2.6.0). Closes KnifeLemon#1616
KnifeLemon
reviewed
Dec 2, 2026
KnifeLemon
left a comment
Owner
There was a problem hiding this comment.
Thanks @cre8ive-marketing, this follows the plan closely:
AtBitrateis reused;- hardware encoding is turned off and there is no stream copy;
- DVD/DV are left out;
- the gallery fields are in.
A few small things before it's ready:
FitAgainAsync(FfmpegConverter.cs:322) re-encodes withAtBitrate(..., kbps)withoutconstant. A CBR preset whose first encode misses the size limit then comes out at an average bitrate on the second pass. And when the set bitrate is lower than the limit's, that pass starts from the limit'skbpsrather than the set one.Apply()(PresetEditorViewModel.cs:1581) keepsConstantBitratewhen the box is greyed. To see it, tick CBR on H.264, then switch to VP9. The engine falls back, so nothing breaks, but&& CanConstantBitratewould keep the saved preset honest.- Tests: the hardware case sets
HardwareEncoding = true, but nothing checks which encoder ran. The editor's "parts" case (the bitrate isn't saved) has no test. - For H.265, ffmpeg's libx265 wrapper ignores
-minrate. So "CBR" there is an average bitrate capped by VBV, not strict CBR. Either addstrict-cbr=1to the existing-x265-params, or word the option so it doesn't promise more than that. CHANGELOG.mdconflicts withmainnow.
# Conflicts: # CHANGELOG.md
…or keeps the preset honest - The second encode for a size limit starts from the set bitrate and stays CBR when asked. - x265 gets strict-cbr=1, since libx265 ignores -minrate. - The editor saves CBR only where the codec takes it. - Tests: no GPU encoder is looked for with a bitrate set; parts save no bitrate; CBR not saved for AV1.
Collaborator
Author
|
Thanks, done in a3071a4:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1616
What changes
MediaOptions.VideoBitrateKbps(0 = off) andMediaOptions.ConstantBitrate.ShowVideoMaxSize), so not for clips, joins, slideshows, VOB or DV.MediaEncoding.AtBitrate(-b:v N -maxrate 1.5N -bufsize 2N), now with aconstantflag.-b:v N -minrate N -maxrate N -bufsize Nfor libx264 and libx265. x264 also gets-x264-params nal-hrd=cbr.HardwareEncodingis turned off, asForSizeLimitdoes.CanCopyVideois false while a bitrate is set, so the video is always encoded.notice.bitrate_lowered_for_size. A second fit pass works as before.presets.video_bitrate_split), and the bitrate isn't saved.vob/dv.videoBitrateKbps(IntRule 0–200000) andconstantBitrateare inSharedPresetRules, and both are inSharedPresetVersions.Fieldsas 2.6.0.Tests (
VideoBitrateTests)Also run
SizeLimitTestsand Core tests: all pass.